/*
 * @Author: xyq
 * @Date: 2021-02-22 09:22:51
 * @LastEditors: xyq
 * @LastEditTime: 2021-03-05 11:31:31
 * @FilePath: \little-eight\src\mobx\login\index.js
 */

//登录成功之后调用mobx里面的方法  将数据存入本地  以便将导航信息渲染到界面
import { getSession, setSession } from '../../utils/utils';
import { action, observable } from 'mobx';
import { getInfo } from '../../service/auth';
class route {
  @observable user = getSession('user') || { isLogin: false, premission: '' };
  @observable loginer = [];
  @observable token = '';
  @observable userType = '';
  @observable permissions = '';
  @action
  loginUser(obj) {
    let user1 = {
      isLogin: true, //登录状态
    };
    this.token = obj.token;
    this.userType = obj.userType;
    this.user = user1;
    setSession('user', user1);
    return 200;
  }
  GetInfo() {
    getInfo('/user/getInfo', this.token).then(res => {
      if (res.code === 200) {
        this.permissions = res.data.permissions;
      }
    });
  }
  getLoginer(data) {
    this.loginer = data;
    console.log(this.loginer);
  }
}
export default route;
